﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class AlbumManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            load_AllAlbum();
        }
    }

    public void load_AllAlbum()
    {
        AlbumRepeater.DataSource = BusLogic.Album.get_ALL_ALBUM();
        AlbumRepeater.DataBind();
    }

    protected void lbtDelete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in AlbumRepeater.Items)
        {
            CheckBox cb = (CheckBox)item.FindControl("cbxCheckAlbum");

            if (cb.Checked == true)
            {
                TextBox txtAlbumId = (TextBox)item.FindControl("txtAlbumId");                
                BusLogic.Album.remove_ALBUM(int.Parse(txtAlbumId.Text));
            }
        }
        load_AllAlbum();
        cbxCheckALLAlbum.Checked = false;
    }

    protected void cbxCheckALLAlbum_CheckedChanged(object sender, EventArgs e)
    {
        if (cbxCheckALLAlbum.Checked == true)
        {
            foreach (RepeaterItem item in AlbumRepeater.Items)
            {
                CheckBox cbxCheckAlbum = item.FindControl("cbxCheckAlbum") as CheckBox;
                cbxCheckAlbum.Checked = true;
            }
        }
        else
        {
            foreach (RepeaterItem item in AlbumRepeater.Items)
            {
                CheckBox cbxCheckAlbum = item.FindControl("cbxCheckAlbum") as CheckBox;
                cbxCheckAlbum.Checked = false;
            }
        }

    }
}
